package org.sanguine.tests.tenderpro.actions;

/**
 * Created with IntelliJ IDEA.
 * Author: Alexey Kuznetsov
 * Date: 19.02.14
 * Time: 15:44
 * SVN $Id$
 */
public class ActionFactory {

    public static Action getInstance(String actionName) {
        if (actionName == null || actionName.isEmpty()) return null;

        try {
            Class actionClass = Class.forName(actionName.trim());
            Object newAction = null;
            try {
                newAction = actionClass.newInstance();
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
            if (newAction instanceof Action) return (Action)newAction;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        return null;
    }
}
